def is_valid_sequence(s):
    a = []
    b = {")": "(", "]": "[", "}": "{", ">": "<"}
    for char in s:
        if char in "([{<":
            a.append(char)
        elif char in ")]}>":
            if not a or a.pop() != b[char]:
                return False
    return not a

sequence = input("Введите скобочную последовательность: ")
print(is_valid_sequence(sequence))
